﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CMN.BLL;
using CMN.Common;
using CMN.Entity;
using CMN.Models.Interfaces;
namespace CMN.Models
{
    /// <summary>
    /// 系统日记表Service
    /// </summary>
    public class Sys_EventService: IDataService<Sys_EventEntity>
    {
        /// <summary>
        /// 新增系统日记表
        /// </summary>
        /// <param name="Sys_EventEntity"></param>
        /// <returns>bool</returns>
        public string Insert(Sys_EventEntity sys_eventEntity)
        {
            sys_eventEntity.DataTable_Action = DataTableAction.Insert;
            BLLHelper bll = new BLLHelper();
            if (bll.Sys_EventInsertUpdateDelete(sys_eventEntity) > 0)
            {
                return "";
            }
            else
            {
                return "失败";
            }
        }

        /// <summary>
        /// 返回系统日记表查询列表
        /// </summary>
        /// <param name="qp"></param>
        /// <param name="count">查询总个数</param>
        /// <returns>List</returns>
        public List<Sys_EventEntity> List(QueryParam qp,out int count)
        {
            BLLHelper bll = new BLLHelper();
            return bll.Sys_EventList(qp, out count);
        }

        /// <summary>
        /// 更新系统日记表
        /// </summary>
        /// <param name="Sys_Event"></param>
        /// <returns>bool</returns>
        public string Update(Sys_EventEntity sys_eventEntity)
        {
            sys_eventEntity.DataTable_Action = DataTableAction.Update;
            BLLHelper bll = new BLLHelper();
            if (bll.Sys_EventInsertUpdateDelete(sys_eventEntity) > 0)
            {
                return "";
            }
            else
            {
                return "失败";
            }
        }

        /// <summary>
        /// 删除系统日记表
        /// </summary>
        /// <param name="Sys_Event"></param>
        /// <returns>bool</returns>
        public string Delete(Sys_EventEntity sys_eventEntity)
        {
            sys_eventEntity.DataTable_Action = DataTableAction.Delete;
            BLLHelper bll = new BLLHelper();
            if (bll.Sys_EventInsertUpdateDelete(sys_eventEntity) > 0)
            {
                return "";
            }
            else
            {
                return "失败";
            }
        }

        /// <summary>
        /// 批量删系统日记表
        /// </summary>
        /// <param name="idList">删除id列表  2_8_9_45</param>
        /// <returns>bool</returns>
        public string DeleteList(string idList)
        {
            string[] list =Utils.SplitString(idList,"_");
            string strDel=Utils.ArrayToString(list,",",false);
            BLLHelper bll = new BLLHelper();
            if (bll.Sys_EventDelList(strDel) > 0)
            {
                return "";
            }
            else
            {
                return "失败";
            }

        }

        /// <summary>
        /// 返回单个系统日记表
        /// </summary>
        /// <param name="id"></param>
        /// <returns>Sys_EventEntity</returns>
        public Sys_EventEntity Look(int id)
        {
            BLLHelper bll = new BLLHelper();
            return bll.Sys_EventDisp(id);
        }
    }
}
